<extend name="Layout/ins_popup" />
<block name="content">
	<div class="popup-frame">
		<input type="hidden" name="val" id="val">
		<input type="hidden" name="name" id="name">
		<div class="popup-header ">
			<div class="pull-left">
				<h1>请选择项目</h1>
			</div>
			<div class="pull-right">
				<a id="save" class="btn">确定</a>
				<a id='close' class="btn btn-cancel">关闭</a>
			</div>
		</div>
		<div class="popup-body">
			<div class="popup-body-scroll">
				<div class="popup-content">
					<div class="layui-input-inline" style="width:100%;">
						<form name="form_search" id="form_search" method="post">
							<input name="keyword" class="layui-input" id="keyword" >							
							<span class="add-on" id="btn_search">搜索</span>
						</form>
					</div>
					<hr style="background:#bbb;">
					<div class="popup_tree_menu">
						<ul class="tree_menu">
							<li>
								{$menu}
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div id="tpl" class="hidden">
		<div class="frame" style="position:relative;">
			<div class="bit-4">
				<input type="hidden" name="content_item_id[]" value="{id}">
				<textarea style="width:100%;height:90px;" name="content_item[]">{name}</textarea>
			</div>
			<div class="bit-4">
				<textarea style="width:100%;height:90px;" name="content[]"></textarea>
			</div>
			<div class="bit-4">
				<textarea style="width:100%;height:90px;" name="finish[]"></textarea>
			</div>
			<div class="bit-4">
				<textarea style="width:100%;height:90px;" name="suggest[]"></textarea>
			</div>
			<a class="del" style="float:right;position:absolute;right:-5px;top:5px;color:red;"><i class="fa fa-times"></i></a>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		layui.use(['global'], function() {
			var $ = layui.jquery;
			$(".popup_tree_menu a").click(function() {
				$this = $(this);
				if ($this.hasClass('active')) {
					$this.removeClass("active");
				} else {
					$this.addClass("active");
				}
			});

			$('#btn_search').on('click', function() {
				$("#form_search").submit();
			});
			//保存后关闭
			$('#save').on('click', function() {
				if ($(".popup_tree_menu a.active").length > 0) {
					$(".popup_tree_menu a.active").each(function() {
						$html = $("#tpl").html();
						id = $(this).attr('node');
						name = $(this).text();
						$html = tpl_parse($html, 'id', id);
						$html = tpl_parse($html, 'name', name);
						$('#content_box', parent.document).append($html);
					});
					parent.layer.close(index);
				} else {
					parent.layer.msg('"请选择"');
					return false;
				}
				parent.layer.close(index);
			});
			//关闭iframe
			$('#close').click(function() {
				parent.layer.close(index);
			});

		});
	</script>
</block>